//
//  GushiPinpaiViewController.m
//  XRSquare
//
//  Created by 穆相臣 on 2018/10/28.
//  Copyright © 2018 UaenaMo. All rights reserved.
//

#import "GushiPinpaiViewController.h"
#import "GushiTableViewCell.h"

@interface GushiPinpaiViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView * contentTableView;
    NSArray * dataArr;
}
@end

@implementation GushiPinpaiViewController

-(void)backAction
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
   
    self.navigationController.navigationBar.tintColor = [UIColor grayColor];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
    
    contentTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
    contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    contentTableView.delegate = self;
    contentTableView.dataSource = self;
    contentTableView.backgroundColor = [UIColor colorFromHexCode:@"f3f3f3"];
    [self.view addSubview:contentTableView];
    [self requestData];
}

-(void)requestData
{
    [NetRequestCenter storyBrandWithUid:self.contentId result:^(BOOL success, NSDictionary *resultDic) {
        if (success)
        {
            dataArr = [resultDic objectForKey:@"data"];
            [contentTableView reloadData];
        }
    }];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [dataArr count];
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return [GushiTableViewCell heightWithData:[dataArr objectAtIndex:indexPath.row]];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * identifer = @"sdsd";
    GushiTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
    if (!cell) {
        cell = [[GushiTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
    }
    [cell loadData:[dataArr objectAtIndex:indexPath.row]];
    return cell;
}

-(BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
    return NO;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}

-(void)showImages:(NSArray *)images
{
    MYPhotoBrowser *photoBrowser = [[MYPhotoBrowser alloc]initWithUrls:images imgViews:nil placeholder:nil currentIdx:index handleNames:nil callback:^(UIImage *handleImage,NSString *handleType) {
        
    }];
    [photoBrowser showWithAnimation:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
